﻿@{
   
    var _url = ViewBag.ActiveUrl as ForumUrl;

    var _list = ViewBag.List as List<Moderator>;
        
}
@model Moderator
<div class="site-block">
    <div class="header">
        @_url.Title
    </div>
    @*<form action="@_url.Url" class="ajax">*@
    @using (Html.Kaio().BeginForm(new jQueryAjaxOptions() { Loading = true }, new { @id = "_f" }))
    {

        @Html.HiddenFor(x => Model.Id)
        @Html.Hidden("returnUrl", _url.Url)
        <div class="site-block-content">
            <table>
                <tr>
                    <td class="w25">
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "USER_NAME")
                    </td>
                    <td>
                        @Html.TextBoxFor(x => Model.UserName, new { @class = "input {validate:{required:1}}" })
                    </td>
                </tr>
                <tr>
                    <td class="v-top">
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "FORUMS_TO_MODERATE")
                    </td>
                    <td>
                        @Html.CheckBoxGroup("Forums", (List<SelectItem>)ViewBag.ForumLists, Model != null ? Model.ForumId : -1, new { @class = "moderate-forum-list" })
                    </td>
                </tr>
                <tr>
                    <td class="caption" colspan="2">
                        @ForumContext.GetText(LanguageSection.MODERATOR_MANAGER, "MODERATE_EMAIL")
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "EMAIL_FOR_NEW_TOPICS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("EmailForNewTopics", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.EmailForNewTopics, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "EMAIL_FOR_NEW_POSTS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("EmailForNewPosts", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.EmailForNewPosts, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "EMAIL_FOR_EDITED_POSTS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("EmailForEditedPosts", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.EmailForEditedPosts, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td class="caption" colspan="2">
                        @ForumContext.GetText(LanguageSection.MODERATOR_MANAGER, "TOPIC_POST_PERMISSIONS")
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "EDIT_TOPICS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("EditTopics", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.EditTopics, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "EDIT_POSTS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("EditPosts", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.EditPosts, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "DEL_TOPICS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("DeleteTopics", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.DeleteTopics, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "DEL_POSTS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("DeletePosts", (List<SelectItem>)ViewBag.YesNo, Model != null && Model.DeletePosts, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td class="caption" colspan="2">
                        @ForumContext.GetText(LanguageSection.MODERATOR_MANAGER, "MODERATION_PERMISSIONS")
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "APPROVE_TOPICS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("ApproveTopics", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.ApproveTopics, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "APPROVE_POSTS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("ApprovePosts", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.ApprovePosts, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "QUEUE_TOPICS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("QueueTopics", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.QueueTopics, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "QUEUE_POSTS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("QueuePosts", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.QueuePosts, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "MOVE_TOPICS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("MoveTopics", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.MoveTopics, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "UNMOVE_TOPICS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("UnMoveTopics", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.UnMoveTopics, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "LOCK_TOPICS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("LockTopics", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.LockTopics, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "UNLOCK_TOPICS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("UnLockTopics", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.UnLockTopics, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "PIN_TOPICS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("PinTopics", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.PinTopics, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @ForumContext.GetMvcText(LanguageSection.MODERATOR_MANAGER, "UNPIN_TOPICS")
                    </td>
                    <td>
                        @Html.RadioButtonGroup("UnPinTopics", (List<SelectItem>)ViewBag.YesNo, Model == null || Model.UnPinTopics, new { @class = "radio-group-panel" })
                    </td>
                </tr>
                <tr>
                    <td>
                    </td>
                    <td>
                        @* @Html.Button(ButtonType.Submit, (string)ViewBag.ButtonText, new { @class = "ui-button" })
                    @Html.Button(ButtonType.Button, ForumContext.GetText(LanguageSection.GLOBAL, "Cancel"), new { @class = "ui-button", @onclick = string.Format("$.MvcForum.jump('{0}')", _url.Url) })*@
                        @Html.Link("javascript://", (string)ViewBag.ButtonText, new { @class = "ui-button", onclick = "$('#_f').submit()" })
                        @Html.Link(_url.Url, ForumContext.GetText(LanguageSection.GLOBAL, "Cancel"), new { @class = "ui-button" })
                    </td>
                </tr>
            </table>
        </div>
    }
</div>
@if (_list != null && _list.Count > 0)
{
    
    <form action="@_url.Url" id="_fl">
    @Html.Hidden("act", "del")
    @Html.Hidden("returnUrl", _url.Url)
    <div class="gridview white-t">
        <div class="head">
            @ForumContext.GetText(LanguageSection.MODERATOR_MANAGER, "MOD_LIST")
        </div>
        <table class="datatable">
            <tr>
                <th class="header w5" scope="col">
                    <input type='checkbox' onclick='$.MvcForum.toggleCheckbox(this.checked)' />
                </th>
                <th class="header" scope="col">
                    @ForumContext.GetText(LanguageSection.MODERATOR_MANAGER, "FORUM_NAME")
                </th>
                <th class="header" scope="col">
                    @ForumContext.GetText(LanguageSection.GLOBAL, "OPTIONS")
                </th>
            </tr>
            @{
    /*(from m in _moderators select Moder {UserName}) */
    var _users = _list.Select(x => x.UserName).Distinct();
    foreach (string u in _users)
    {

        var _moderaters = _list.FindAll(x => x.UserName == u);
                    
                <tr>
                    <td class="site-block-head bold" colspan="3">
                        @u
                    </td>
                </tr>

        foreach (Moderator x in _moderaters)
        {
                        
                <tr class="row">
                    <td class="center">
                        <input type="checkbox" name="Ids" value="@x.Id" class="selected" />
                    </td>
                    <td>
                        @x.ForumName
                    </td>
                    <td class="center width10">
                        @*@Html.Link(string.Format("{0}?Id={1}", _url.Url, m.Id), ForumContext.GetText(LanguageSection.GLOBAL, "Edit"), null)*@
                        @Html.Link(string.Format("{0}?Id={1}", (string)ViewBag.Url, x.Id), "", new { @class = "ui-button icon-16 edit" })
                    </td>
                </tr>
                        
        }

    }
            }
        </table>
    </div>
    <div class="white-t">
        @Html.Link("javascript:void(0)", "", new { @onclick = "$.KoolBox.confirm('" + ForumContext.GetText(LanguageSection.MESSAGES, "DELETE_CONFIRM") + "',{title:'Confirm'},function(r){if(r){$.MvcForum.ajaxSubmit('_fl')}})", @class = "ui-button icon-16 del" })
    </div>
    </form>
    
}
